package reading.util.utils;

import java.util.StringTokenizer;

/**
 * ${DESCRIPTION}
 *
 * @author txw
 * @since 2018-12-14 14:57
 **/
public class HtmlUtil {
    /**
     * 文本转 p 标签包裹
     *
     * @param str
     * @return
     */
    public static String toP(String str) {
        if (str != null) {
            StringBuilder stringBuilder = new StringBuilder("");
            StringTokenizer stringTokenizer = new StringTokenizer(str, "\n");
            while (stringTokenizer.hasMoreTokens()) {
                String s = "<p>" + stringTokenizer.nextToken() + "</p>";
                stringBuilder.append(s);
            }
            return stringBuilder.toString();
        }

        return null;
    }
}
